#ifndef GENEREGIONVIEWERMENUSIDEBAR_H
#define GENEREGIONVIEWERMENUSIDEBAR_H

#include <QObject>
#include <QGraphicsWidget>
#include <QPainterPath>
#include <QRectF>
#include <QStyleOptionGraphicsItem>
#include <QGraphicsLinearLayout>
#include <QDebug>
#include <QRectF>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include <QSlider>
#include <QComboBox>
#include <QDate>

#include "multigeneregionviswidget.h"

class GeneRegionViewerMenuSideBar;

class SideBarPixmap : public QGraphicsProxyWidget
{
    Q_OBJECT
public:
    SideBarPixmap( QString pixmapFile, QString highlightedPixmapFile, float width, QGraphicsWidget* parent = 0);
    float width;

    float yPos();
    float height();

signals:
    void clicked();

public slots:
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event);

private:
    QLabel* label;
    QPixmap* pixmap;
    QPixmap* highlightedPixmap;


};

class ProjectMenu : public QGraphicsWidget
{
    Q_OBJECT
public:
    ProjectMenu( GeneRegionViewerMenuSideBar* parent = 0);

    //these allow elts to be drawn
    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget);

    void setWidth(float newWidth);
    void setHeight(float newHeight);
private:
    float width;
    float height;

    QGraphicsLinearLayout* layout;
    QGraphicsLinearLayout* saveLayout;

    QLabel* saveLabel;
    QGraphicsProxyWidget* saveLabelProxy;

    QLineEdit* saveLineEdit;
    QGraphicsProxyWidget* saveLineEditProxy;

    SideBarPixmap* choose;


};

class SortMenu : public QGraphicsWidget
{
  Q_OBJECT
public:
    SortMenu( GeneRegionViewerMenuSideBar* parent = 0);

    //these allow elts to be drawn
    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget);

    void setWidth(float newWidth);
    void setHeight(float newHeight);

public slots:
    void sortByElementClicked();

signals:
    void sortByElement(QString elt, QString type);

private:
    float width;
    float height;

    QGraphicsLinearLayout* layout;
    QGraphicsLinearLayout* contigLengthSortLayout;
    QGraphicsLinearLayout* sortByLayout;
    QGraphicsLinearLayout* typeAndGoLayout;

    QPushButton* longToShortButton;
    QGraphicsProxyWidget* longToShortButtonProxy;

    SideBarPixmap* longToShort;
    SideBarPixmap* shortToLong;
    SideBarPixmap* restoreOriginalOrder;

    QLabel* sortByText;
    QGraphicsProxyWidget* sortByTextProxy;
    QLineEdit* userEntry;
    QGraphicsProxyWidget* userEntryProxy;
    QComboBox* sortType;
    QGraphicsProxyWidget* sortTypeProxy;

    SideBarPixmap* goSideBarPixmap;

};


class GeneRegionViewerMenuSideBar : public QGraphicsWidget
{
    Q_OBJECT
public:
    GeneRegionViewerMenuSideBar( MultiGeneRegionVisWidget *parent = 0 );

    //these allow elts to be drawn
    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget);

    void setWidth(float newWidth);
    void setHeight(float newHeight);

signals:

    void heightChangeSignal(int newHeightFactor);
    void zoomChangeSignal(int newNtPerPixel);

    void sortByContigLengthLongToShortSignal();
    void sortByContigLengthShortToLongSignal();

    void sortByEntrySignal(QString entry, QString field);

public slots:
    void toggleProjectMenuVisibility();
    void toggleSortMenuVisibility();

private:
    float width;
    float height;

    QGraphicsLinearLayout* layout;

    SideBarPixmap* project;
    SideBarPixmap* search;
    SideBarPixmap* sort;
    SideBarPixmap* color;
    //SideBarPixmap* filter;
    //SideBarPixmap* sequence;
    //SideBarPixmap* link;

    QGraphicsLinearLayout* contigHeightLayout;
    SideBarPixmap* contigHeightSideBarPixmap;
    QSlider* contigHeightSlider;
    QGraphicsProxyWidget* contigHeightSliderProxy;

    QLabel* zoomLabel;
    QGraphicsProxyWidget* zoomLabelProxy;

//   SideBarPixmap* zoomSliderPixmap;
    QSlider* zoomSlider;
    QGraphicsProxyWidget* zoomSliderProxy;
//    QPushButton* zoomInButton;
//    QGraphicsProxyWidget* zoomInButtonProxy;
//    QPushButton* zoomOutButton;
//    QGraphicsProxyWidget* zoomOutButtonProxy;
//    QGraphicsLinearLayout* zoomButtonLayout;

//    SideBarPixmap* zoom;


    SortMenu* sortMenu;
    QGraphicsProxyWidget* sortMenuProxy;

    ProjectMenu* projectMenu;
    QGraphicsProxyWidget* projectMenuProxy;

};

#endif // GENEREGIONVIEWERMENUSIDEBAR_H
